//
//  ZH_MineBankCardViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/23.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_MineBankCardViewController.h"
#import "ZH_MineBankCardTableViewCell.h"
@interface ZH_MineBankCardViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,weak)UITableView *tableView;
@property (nonatomic,weak)UIButton *button;
@property (nonatomic,weak)UIImageView *bottomImage;
@property (nonatomic,weak)UILabel *bottomLabel;

@end

@implementation ZH_MineBankCardViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
}

- (void)initUserInterface{
    self.navigationItem.title = @"银行卡";
    self.view.backgroundColor = kCommonBackgroudColor;
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.mas_equalTo(FITSCALE(365));
    }];
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tableView.mas_bottom).offset(FITSCALE(60));
        make.left.equalTo(self.view).offset(FITSCALE(22));
        make.right.equalTo(self.view).offset(FITSCALE(-22));
        make.height.mas_equalTo(FITSCALE(46));
    }];
    [self.bottomImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.button.mas_bottom).offset(FITSCALE(30));
        make.left.equalTo(self.view).offset(FITSCALE(85));
    }];
    [self.bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.bottomImage);
        make.left.equalTo(self.bottomImage.mas_right).offset(FITSCALE(4));
    }];

}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 7;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"姓名:";
        [cell rightImageHidden:YES];
        [cell textFieldHidden:NO];
        return cell;
    }
    else if (indexPath.row == 1) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"手机号码:";
        [cell rightImageHidden:YES];
        [cell textFieldHidden:NO];
        return cell;
    }
    else if (indexPath.row == 2) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"银行卡号:";
        [cell rightImageHidden:YES];
        [cell textFieldHidden:NO];
        return cell;
    }
    else if (indexPath.row == 3) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"所属银行:";
        [cell rightImageHidden:YES];
        [cell textFieldHidden:NO];
        return cell;
    }
    else if (indexPath.row == 4) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"支行名称:";
        [cell rightImageHidden:YES];
        [cell textFieldHidden:NO];
        return cell;
    }
    else if (indexPath.row == 5) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"所属省份:";
        [cell rightImageHidden:NO];
        [cell textFieldHidden:YES];
        return cell;
    }
    else if (indexPath.row == 6) {
        ZH_MineBankCardTableViewCell *cell = [ZH_MineBankCardTableViewCell cellWithTableView:tableView];
        cell.leftString = @"所属城市:";
        [cell rightImageHidden:NO];
        [cell textFieldHidden:YES];
        return cell;
    }
    return nil;
}
#pragma mark - getter,setter
- (UITableView *)tableView{
    if(!_tableView){
        UITableView *tableView = [UITableView createTableViewWithDelegateTarget:self];
        tableView.backgroundColor = kCommonWhiteBg;
        tableView.scrollEnabled = NO;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [tableView setCellAutoAdaptationForEstimatedRowHeight:FITSCALE(49)];
        [self.view addSubview:_tableView = tableView];
    }
    return _tableView;
}
- (UIButton *)button{
    if (!_button) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"确认" target:self action:nil];
        button.backgroundColor = [UIColor colorWithHexString:@"#00C9AE"] ;
        [button setTitleColor:kFontColorWhite forState:UIControlStateNormal];
        button.layer.cornerRadius = FITSCALE(22);
        button.layer.masksToBounds = YES;
        button.clipsToBounds = YES;
        [self.view addSubview:_button = button];
    }
    return _button;
}
- (UIImageView *)bottomImage{
    if (!_bottomImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_ts"];
        [self.view addSubview:_bottomImage = image];
    }
    return _bottomImage;
}
- (UILabel *)bottomLabel{
    if (!_bottomLabel) {
        UILabel *label = [UILabel createLabelWithText:@"温馨提示: 如果需要修改, 请联系客服564648" font:kFontSize_24];
        label.textColor = [UIColor colorWithHexString:@"#999999"];
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:label.text];
        NSDictionary *dic = @{NSFontAttributeName:kFontSize_22,NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FE4949"]};
        [attr setAttributes:dic range:[label.text rangeOfString: @"564648"]];
        label.attributedText = attr;
        [self.view addSubview:_bottomLabel = label];
    }
    return _bottomLabel;
}

@end
